package com.coreservlets.jsf.ss08;

public class RandPageNavigation
{
	private String source;
	
	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String doRandFromPageA()
	{
		String[] pageOptions = { "PageB", "Defeat" };
		
		return( pageOptions[ new java.util.Random().nextInt(2)]);
	}
	
	public String doRandFromPageB()
	{
		String[] pageOptions = { "PageC", "Defeat" };
		
		return( pageOptions[ new java.util.Random().nextInt(2)]);
	}
	
	public String doRandFromPageC()
	{
		String[] pageOptions = { "Victory", "Defeat" };
		
		return( pageOptions[ new java.util.Random().nextInt(2)]);
	}
	
	public String doRandNav()
	{
		if( getSource().equals( "PageA" ) )
		{
			return( doRandFromPageA() );
		}
		else if( getSource().equals( "PageB"))
		{
			return( doRandFromPageB() );
		}
		else
		{
			return( doRandFromPageC() );
		}
	}
}
